"use strict";
function addlog(str) {
    var sp = document.createElement("span");
    sp.textContent = str;
    document.body.appendChild(sp);
    var nl = document.createElement("hr");
    document.body.appendChild(nl);
}
window.onload = function () {
    var url = window.location.href;
    addlog("Jmp back url=" + url);
    window.addEventListener("message", function (e) {
        if (e.data["cmd"] == undefined)
            return;
        var cmd = e.data["cmd"];
        if (cmd == "jmpto") {
            window.open(e.data["url"], "_self");
            return;
        }
        if (cmd == "close") {
            window.close();
        }
    });
    try {
        window.opener.postMessage({ "cmd": "backcall", "url": url }, "*");
        addlog("window.opener.postMessage succ.");
        history.go(-2);
    }
    catch (_a) {
        addlog("window.opener.postMessage fail.");
    }
};
